package com.zkyc.framework.schedulejob.task;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringPool;
import com.zkyc.framework.common.mapper.TimingMapper;
import com.zkyc.framework.common.mapper.WebClickRateMapper;
import com.zkyc.framework.common.pojo.SystemTiming;
import com.zkyc.framework.common.pojo.WebClickRate;
import com.zkyc.framework.common.utils.WebsiteUtil;
import com.zkyc.framework.schedulejob.config.JedisPoolFactory;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

import static com.zkyc.framework.common.constant.Constant.*;

/**
 * @description 每天插入页面请求数据
 */
@Slf4j
@Component
public class TimingTask {
    @Autowired
    private TimingMapper timingMapper;

    /**
     * 每天零点同步一次
     */
    @Scheduled(cron = "0 0 0 * * ?")
    //@Scheduled(cron = "*/5 * * * * ?")
    public void process() {
        List<String> websiteIds = timingMapper.getAllWebsite();
        for (String websiteId : websiteIds) {
            SystemTiming systemTiming = new SystemTiming();
            systemTiming.setWebsiteId(websiteId);
            systemTiming.setCostTime(0);
            systemTiming.setMethodName("process");
            systemTiming.setRequestDate(new Date());
            timingMapper.insert(systemTiming);
        }
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("timing执行可");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
        System.out.println("----------------------");
    }
}
